// pages/classification/classification.js
var call = require('../../utils/request')
Page({

  /**
   * 页面的初始数据
   */
  data: {
    inputValue:'',
    btnId:0,
    keyword:'猪肉',
    cuisine:[
      {
        title:"猪肉",
        num:20
      },
      {
        title:"鱼肉",
        num:20
      },
      {
        title:"牛肉",
        num:20
      },{
        title:"鸡肉",
        num:20
      },{
        title:"鸭肉",
        num:20
      },{
        title:"包菜",
        num:20
      },{
        title:"白菜",
        num:20
      },{
        title:"青菜",
        num:20
      },{
        title:"空心菜",
        num:20
      },{
        title:"卷心菜",
        num:20
      },
      {
        title:"豆腐",
        num:20
      },
    ],
    list:[],
    nodes:[]

  },
  bindKeyInput: function (e) {
    this.setData({
      keyword: e.detail.value
    })
  },
  jump:function(e){
    console.log(e,'e')
    let that = this
    console.log(e.currentTarget.dataset.id,'id')
    let id = e.currentTarget.dataset.id
    let title = e.currentTarget.dataset.title
    that.setData({ btnId: id,keyword:e.currentTarget.dataset.title})
    // that.setData({keyword:e.currentTarget.dataset.title})
    // 调用接口
    that.dateList()
  },
  submit_btn(){
    let that= this;
    that.dateList()
  },
  dateList:function(){
    var that = this;
    //参数
    let url='/recipe/search'
    console.log(that.data.keyword,'888888888888')
    let date={
      keyword:that.data.keyword,
      num:20,
      appkey:'928cbbc1f0636217'
    }
    call.request(url,date).then(res => {
      // console.log('dddd', res)
      // console.log('dddd', res.data.result.list)
      that.setData({list:res.data.result.list})
    })
  },
  details:function(e) {
    let that = this;
    console.log(e, 'e')
    let date = {}
    // let name = e.currentTarget.dataset.name
    date.name = e.currentTarget.dataset.name
    date.id = e.currentTarget.dataset.id
    wx.navigateTo({
      url: '../details/details?date=' + JSON.stringify(date)
    })
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    let that = this;
    that.dateList()
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})